﻿using Fuse8.DomainFramework.BusinessService;
using System;
using System.Xml.Serialization;

namespace Fuse8.ContentManagementFramework.Domain
{
    [Serializable]
    public partial class CmsDomain : CmsTrackingEntityObject
    {
        #region Linked field

        private CmsSite _site;

        #endregion Linked field

        #region Properties

        public virtual int SiteId { get; set; }

        public virtual string Hostname { get; set; }

        #endregion Properties

        #region Linked property

        [XmlIgnore]
        public CmsSite Site
        {
            get
            {
                if (_site == null)
                {
                    if (SiteId != 0)
                    {
                        var businessFacade = new BusinessServiceFacade<CmsSite, int>();
                        if (businessFacade != null)
                        {
                            _site = businessFacade.FindOne(SiteId);
                        }
                    }
                }

                return _site;
            }
            set
            {
                SiteId = value != null ? value.Id : 0;

                _site = null;
            }
        }

        #endregion Linked property

        #region Constructor

        public CmsDomain()
        { }

        #endregion Constructor

        #region EntityObject override

        public override string TypeParameter
        {
            get
            {
                return "Domain";
            }
        }

        #endregion EntityObject override
    }
}